package com.yowasa.xiuxian.engine.item.tuzhi;

import com.yowasa.xiuxian.annoations.Item;
import com.yowasa.xiuxian.engine.item.ItemInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ItemTypeEnum;
import com.yowasa.xiuxian.exception.HandlerException;

import java.text.MessageFormat;


@Item(name = "千岩同心图纸", type = ItemTypeEnum.TU_ZHI, price = 5000)
public class QianYanTongXinTuzhi implements ItemInterface {

    @Override
    public String desc() {
        return "璃月的千岩汇聚成了这件神奇的装备，提供物抗，法抗，血量";
    }

    @Override
    public String effect(UserBO userBO) {
        if(userBO.getUserConfig().getTravel() < this.getPrice() / 2){
            throw new HandlerException(MessageFormat.format("你的历练值不够，无法学习[{0}/{1}]", userBO.getUserConfig().getTravel(), this.getPrice() / 2));
        }else {
            userBO.getUserConfig().setTravel(userBO.getUserConfig().getTravel() - (this.getPrice()/2));
        }

        if (userBO.getUserConfig().getKnownEquipDrawing().contains(this.getName())) {
            return "你学会了装备【" + this.getName().substring(0,this.getName().length()-2) + "】的锻造之法,但是你已经知晓了";
        } else {
            userBO.getUserConfig().getKnownEquipDrawing().add(this.getName());
            return "你学会了装备【" + this.getName().substring(0,this.getName().length()-2) + "】的锻造之法";
        }
    }
}

